package cn.com.elite;

import java.util.List;

import javax.sql.DataSource;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;

public class MYBean {
	private static final Log log=LogFactory.getLog(MYBean.class);
	private DataSource dataSource;
    private DataSourceTransactionManager tran;
	public DataSource getDataSource() {
		return dataSource;
	}
	public void setDataSource(DataSource dataSource) {
		this.dataSource = dataSource;
	}
	public DataSourceTransactionManager getTran() {
		return tran;
	}
	public void setTran(DataSourceTransactionManager tran) {
		this.tran = tran;
	}
	public List chaxun_sql(String sql,DataSource dataSource1){
		List result=null;
		try{
			JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource1);
			result=jdbcTemplate.queryForList(sql);
		}catch(Exception e){
			log.error("chaxun_sql_ERRO:"+Util.getERRO(e));
		}
		return result;
	}
	
	public int update_sql(String sql,DataSource dataSource1){
		int result=0;
		try{
			JdbcTemplate jdbcTemplate=new JdbcTemplate(dataSource1);
			result=jdbcTemplate.update(sql);
		}catch(Exception e){
			log.error("chaxun_sql_ERRO:"+Util.getERRO(e));
		}
		log.info(sql+":"+result);
		return result;
	}
}
